import java.util.HashMap;
import java.util.Map;

public class Tracker {
	private final Map<String, Point> map;

	public Tracker(Map<String, Point> map) {
		this.map = new HashMap<String, Point>();
		if (map != null) {
			for (String id : map.keySet()) {
				this.map.put(id, new Point(map.get(id)));
			}
		}
	}

	public Point getLoc(String id) {
		synchronized (map) {
			Point point = map.get(id);
			if (point == null) {
				return null;
			} else {
				return new Point(point);
			}
		}
	}

	public void setLoc(String id, Point point) {
		synchronized (map) {
			map.put(id, new Point(point));
		}
	}

	public Map<String, Point> getLocations() {
		synchronized (map) {
			Map<String, Point> result = new HashMap<String, Point>();
			for (String id : map.keySet()) {
				result.put(id, new Point(map.get(id)));
			}
			return result;
		}
	}
}
